package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/captcha")
public class CodeController {
@RequestMapping("/toCode")
    public String toCode(){
    return "code";
}

@RequestMapping("/test1")
    public String test1(String captcha, HttpServletRequest request){
    //1. 从session会话中获取, 会话中保存的验证码
    String sessionCode = (String) request.getSession().getAttribute("captcha");



    //2. 使用会话中的验证码和用户输入的验证码进行比较

    if (sessionCode.equalsIgnoreCase(captcha)){
        System.out.println("---验证码正确------");
    }else {
        System.out.println("-----验证码错了，我擦---");
    }
    return "hello";
}


}
